using System;
using System.Linq;
using System.Windows.Forms;
using Linquid;
using Linquid.Controls;

namespace LinquidCFSamples
{
	public class Samples
	{
		public static UI<Source<string>> Sample1 =
			from text in UIM.Input()
			let doubledText = 
				from s in text
				select s + s
			from _ in UIM.Output(doubledText)
			select doubledText;	
		
		public static UI<Source<int>> Sample2 =
			from i1 in UIM.Slider(0, 10).Title("Value 1")
			from i2 in UIM.Slider(0, 10).Title("Value 2")
			from op in UIM.Choice("Sum", "Sum", "Product").Title("Operation")
			orderby LayoutDirection.FromTop
			from click in UIM.Button("Go")
			orderby LayoutDirection.FromLeft
			let result = 
				from x in i1
				from y in i2
				from name in op
				orderby click
				let r = name == "Sum" ? x + y : x * y				
				select r 
			from _ in UIM.Output(result).Title("Result")
			orderby LayoutDirection.FromTop
			group result by "The ultimate arithmetic machine";
		
		public static UI<Source<string>> Sample3 =
			UIM.Insert(font => new TextBox()
			           {
			           		Multiline = true,
			           		Font = font,
			           		ScrollBars = ScrollBars.Vertical,
			           		Width = 300,
			           		Height = 300
			           },
			           textBox => textBox.TextSource(),
			           1.0f, 1.0f);
	}
}